
******************************************************************************************************************************
******************************************************************************************************************************
******************** 	REPLICATION FOR: 																	 *****************
********************	Policy Influence of Delegates in Authoritarian Legislatures: Evidence from China     *****************
******************************************************************************************************************************
******************************************************************************************************************************
** Author: Dongshu Liu
** Last Updated: April 30, 2022
** Environment: 
*** Stata 17.0 BE
*** MacOS Monterey 12.3.1
*** 32GB RAM



****Packages required*****
ssc install reghdfe
ssc install ftools
ssc install interflex



******************************************************************************************************************
******************************************************************************************************************
**************************************************** ANALYSIS ****************************************************
******************************************************************************************************************
******************************************************************************************************************




*************************************************************************************
*************************************************************************************
*************************************************************************************
**# 2014 Analysis      **************************************************************
*************************************************************************************
*************************************************************************************
*************************************************************************************

clear
use "anhui_data_replicate.dta"


drop if year==2016




**Main Regression Model
regress response c.distance##c.interests sponsor money male ethnic_m ccp i.agency i.location, cluster(delegate_no)
margins, dydx(distance) at(interests=(0(1)1))
marginsplot,title("Marginal Effect of Distance to the Regime on Response Level:2014", size(medium)) level(95)/*
*/ ytitle ("Marginal Effect on Response Level", color(black) size(small)) /*
*/xtitle ("Proposal Type", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/yline(0, lc(black) lp(dash)) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) xscale(range(-0.15 1.15)) /*
*/note("Note:95% CI;", size(vsmall)) 
gr save margin_distance, replace
gr export margin_distance.png, replace
gr export margin_distance.eps, replace

margins, at(distance=(1(1)5) interests=(0 1)) atmeans
marginsplot,title("Predicted Response Level on Regime Distance: 2014", size(medium)) level(95)/*
*/ ytitle ("Response Level (1-4)", color(black) size(small)) /*
*/xtitle ("Regime Distance", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) /*
*/note("Note:95% CI;", size(vsmall)) 
gr save margin_distance_predict, replace
gr export margin_distance_predict.png, replace
gr export margin_distance_predict.eps, replace




eststo clear
eststo: quietly regress response c.distance##c.interests

eststo: quietly regress response c.distance##c.interests sponsor money male ethnic_m ccp i.agency i.location, cluster(delegate_no)
eststo: quietly regress response c.distance##c.interests money sponsor male ccp ethnic_m edu age i.agency i.location, cluster(delegate_no)


esttab using main_reg_2013.rtf, keep(distance interests c.distance#c.interests money sponsor male ccp ethnic_m edu age _cons) b(%9.3fc) label replace se ///
stats(N r2, fmt(%9.3fc) labels("Observations" "R2")) ///
star(* 0.05 ** 0.01 *** 0.001) eqlabels("") title(Regression Results )

eststo clear


****Ordinal Logit
eststo clear
eststo: quietly olog response c.distance##c.interests
eststo: quietly olog response c.distance##c.interests money sponsor male ethnic_m ccp i.agency i.location, cluster(delegate_no)
eststo: quietly olog response c.distance##c.interests money sponsor male ethnic_m ccp edu age i.agency i.location, cluster(delegate_no)

esttab using main_olog_2013.rtf, keep(distance interests c.distance#c.interests money sponsor male ccp ethnic_m edu age) b(%9.3fc) label replace se ///
stats(N r2_p chi2, fmt(%9.3fc) labels("Observations" "pseudo-R2" "Chi-Squared")) ///
star(* 0.05 ** 0.01 *** 0.001) eqlabels("") title(Regression Results )

eststo clear


*** Distance as Dummy****
regress response i.distance##c.interests sponsor money male ethnic_m ccp i.agency i.location, cluster(delegate_no)


margins, dydx(interests) at(distance=(1(1)5))
marginsplot,title("Marginal Effect of Proposal Interests on Response Level:2014", size(medium)) level(95)/*
*/ ytitle ("Response Level(1-4)", color(black) size(small)) /*
*/xtitle ("Regime Distance (Categorical)", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/yline(0, lc(black) lp(dash)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) /*
*/note("Note:95% CI; For Interests: 0 (Particularistic) 1 (Universalistic)", size(vsmall)) 
gr save margin_distance_predict, replace
gr export margin_distance_predict_dummy.png, replace
gr export margin_distance_predict_dummy.eps, replace


***Response as Binary***
preserve 
recode response 1=0 2=0 3=1 4=1

logit response c.distance##c.interests sponsor money male ethnic_m ccp i.agency i.location, cluster(delegate_no)
margins, dydx(distance) at(interests=(0(1)1))
marginsplot,title("Marginal Effect of Distance to the Regime on Response (Binary): 2014", size(small)) level(95)/*
*/ ytitle ("Marginal Effect on Response Level", color(black) size(small)) /*
*/xtitle ("Proposal Type", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/yline(0, lc(black) lp(dash)) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) xscale(range(-0.15 1.15)) /*
*/note("Note:95% CI; Response is Binary", size(vsmall)) 
gr save margin_distance, replace
gr export margin_distance_logit.png, replace
gr export margin_distance_logit.eps, replace

restore


***Recoding Response Level***
gen res=response
recode res 4=3

gen res2=response
recode res2 3=2 4=3

gen res3=response
recode res3 2=1 4=3 3=2


eststo clear
eststo: quietly regress res c.distance##c.interests money sponsor male ccp ethnic_m i.agency i.location, cluster(delegate_no)
eststo: quietly regress res2 c.distance##c.interests money sponsor male ccp ethnic_m i.agency i.location, cluster(delegate_no)
eststo: quietly regress res3 c.distance##c.interests money sponsor male ccp ethnic_m i.agency i.location, cluster(delegate_no)






esttab using main_reg_check_2013.rtf, keep(distance interests c.distance#c.interests money sponsor male ccp ethnic_m _cons) b(%9.3fc) label replace se ///
stats(N r2, fmt(%9.3fc) labels("Observations" "R2")) ///
star(* 0.05 ** 0.01 *** 0.001) eqlabels("") title(Regression Results )

eststo clear





***Matching***
gen outsider=1 if distance>3
replace outsider=0 if distance<=3
gen int_bi=1 if interests==0 
replace int_bi=0 if interests==1
tab int_bi



eststo clear
eststo: teffects nnmatch (response money sponsor male ccp ethnic_m location) (outsider) if int_bi==1, nneighbor(1)
eststo: teffects nnmatch (response money sponsor male ccp ethnic_m location ) (outsider) if int_bi==1, nneighbor(2)
eststo: teffects nnmatch (response money sponsor male ccp ethnic_m location ) (outsider) if int_bi==1, nneighbor(4)
eststo: teffects nnmatch (response money sponsor male ccp ethnic_m location ) (outsider) if int_bi==1, nneighbor(8)
esttab using outsider_matching_2014_par.rtf, pr2(2) b(2) se(2) starlevels(* 0.1 ** .05 *** .01) label replace
eststo clear


eststo clear
eststo: teffects nnmatch (response money sponsor male ccp ethnic_m location ) (outsider) if int_bi==0, nneighbor(1)
eststo: teffects nnmatch (response money sponsor male ccp ethnic_m location ) (outsider) if int_bi==0, nneighbor(2)
eststo: teffects nnmatch (response money sponsor male ccp ethnic_m location ) (outsider) if int_bi==0, nneighbor(4)
eststo: teffects nnmatch (response money sponsor male ccp ethnic_m location ) (outsider) if int_bi==0, nneighbor(8)



esttab using outsider_matching_2014_uni.rtf, pr2(2) b(2) se(2) starlevels(* 0.1 ** .05 *** .01) label replace
eststo clear





******NO Difference in asking universal request
gen int3=1 if interests==1
replace int3=0 if interests==0
eststo:logit int3 distance i.location i.agency, robust cluster(delegate_no)

eststo:logit int3 distance sponsor money male ethnic_m ccp i.location i.agency, robust cluster(delegate_no)
eststo:logit int3 distance sponsor money male ethnic_m ccp edu age i.location i.agency, robust cluster(delegate_no)


esttab using request_log_2013.rtf, keep(distance money sponsor male ccp ethnic_m edu age _cons) b(%9.3fc) label replace se ///
stats(N r2_p chi2, fmt(%9.3fc) labels("Observations" "pseudo-R2" "Chi-Squared")) ///
star(* 0.05 ** 0.01 *** 0.001) eqlabels("") title(Regression Results )


eststo clear


*************Interaction Effect Test (HMX)
twoway (sc response distance) (lowess response distance),by(, title("Scatter Plot: 2014")) by(interests)  ytitle(Response) xtitle(Distance) saving(scatter,replace)
gr export plot123.png,replace


interflex response distance interests money sponsor male ccp ethnic_m, fe(agency location) type(linear) vce(cluster) xd(density) xlab("Request of Interests") /*
*/ylab("Level of Responses") dlab("Regime Distance") cluster(delegate_no) title("Linear Estimation of Interaction Effect (2014)") sav(123_interaction_test_density.eps)

interflex response distance interests money sponsor male ccp ethnic_m, fe(agency location) type(kernel) vce(cluster) xd(density) xlab("Request of Interests") /*
*/ylab("Level of Responses") dlab("Regime Distance") cluster(delegate_no) bw(0.2244) title("Kernel Estimation of Interaction Effect (2014)") sav(123_interaction_test_kernel.eps)

interflex response interests distance money sponsor male ccp ethnic_m, fe(agency location) type(linear) vce(cluster) xd(density) xlab("Regime Distance") /*
*/ylab("Level of Responses") dlab("Proposal Interests") cluster(delegate_no) title("Linear Estimation of Interaction Effect (2014)") sav(123_interaction_test_density2.eps)

interflex response interests distance money sponsor male ccp ethnic_m, fe(agency location) type(kernel) vce(cluster) xd(density) xlab("Regime Distance") /*
*/ylab("Level of Responses") dlab("Proposal Interests") cluster(delegate_no) bw(0.2244) title("Kernel Estimation of Interaction Effect (2014)") sav(123_interaction_test_kernel2.eps)







*****Different Coding of Distance**

regress response c.distance2##c.interests sponsor money male ethnic_m ccp i.agency i.location, cluster(delegate_no)
margins, dydx(distance2) at(interests=(0(1)1))
marginsplot,title("Marginal Effect of Distance (Distance Recode 4):2014", size(medium)) level(95)/*
*/ ytitle ("Marginal Effect on Response Level", color(black) size(small)) /*
*/xtitle ("Proposal Type", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/yline(0, lc(black) lp(dash)) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) xscale(range(-0.15 1.15)) /*
*/note("Note:95% CI", size(vsmall)) 
gr save margin_distance_robust4, replace
gr export margin_distance_robust4.png, replace
gr export margin_distance_robust4.eps, replace


margins, at(distance2=(1(1)6) interests=(0 1)) atmeans
marginsplot,title("Marginal Effect of Distance (Distance Recode 4):2014", size(medium)) level(95)/*
*/ ytitle ("Response Level (1-4)", color(black) size(small)) /*
*/xtitle ("Regime Distance", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) /*
*/note("Note:95% CI", size(vsmall)) 
gr save margin_distance_predict_robust4, replace
gr export margin_distance_predict_robust4.png, replace
gr export margin_distance_predict_robust4.eps, replace





regress response c.distance3##c.interests sponsor money male ethnic_m ccp i.agency i.location, cluster(delegate_no)
margins, dydx(distance3) at(interests=(0(1)1))
marginsplot,title("Marginal Effect of Distance (Distance Recode 1):2014", size(medium)) level(95)/*
*/ ytitle ("Marginal Effect on Response Level", color(black) size(small)) /*
*/xtitle ("Proposal Type", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/yline(0, lc(black) lp(dash)) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) xscale(range(-0.15 1.15)) /*
*/note("Note:95% CI", size(vsmall)) 
gr save margin_distance_robust1, replace
gr export margin_distance_robust1.png, replace
gr export margin_distance_robust1.eps, replace


margins, at(distance3=(1(1)5) interests=(0 1)) atmeans
marginsplot,title("Marginal Effect of Distance Response Level (Distance Recode 1):2014", size(medium)) level(95)/*
*/ ytitle ("Response Level (1-4)", color(black) size(small)) /*
*/xtitle ("Regime Distance", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) /*
*/note("Note:95% CI", size(vsmall)) 
gr save margin_distance_predict_robust1, replace
gr export margin_distance_predict_robust1.png, replace
gr export margin_distance_predict_robust1.eps, replace




regress response c.distance4##c.interests sponsor money male ethnic_m ccp i.agency i.location, cluster(delegate_no)
margins, dydx(distance4) at(interests=(0(1)1))
marginsplot,title("Marginal Effect of Distance (Distance Recode 3):2014", size(medium)) level(95)/*
*/ ytitle ("Marginal Effect on Response Level", color(black) size(small)) /*
*/xtitle ("Proposal Type", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/yline(0, lc(black) lp(dash)) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) xscale(range(-0.15 1.15)) /*
*/note("Note:95% CI", size(vsmall)) 
gr save margin_distance_robust3, replace
gr export margin_distance_robust3.png, replace
gr export margin_distance_robust3.eps, replace


margins, at(distance4=(1(1)6) interests=(0 1)) atmeans
marginsplot,title("Marginal Effect of Distance (Distance Recode 3):2014", size(medium)) level(95)/*
*/ ytitle ("Response Level (1-4)", color(black) size(small)) /*
*/xtitle ("Regime Distance", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) /*
*/note("Note:95% CI", size(vsmall)) 
gr save margin_distance_predict_robust3, replace
gr export margin_distance_predict_robust3.png, replace
gr export margin_distance_predict_robust3.eps, replace



regress response c.distance5##c.interests sponsor money male ethnic_m ccp i.agency i.location, cluster(delegate_no)
margins, dydx(distance5) at(interests=(0(1)1))
marginsplot,title("Marginal Effect of Distance (Distance Recode 2):2014", size(medium)) level(95)/*
*/ ytitle ("Marginal Effect on Response Level", color(black) size(small)) /*
*/xtitle ("Proposal Type", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/yline(0, lc(black) lp(dash)) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) xscale(range(-0.15 1.15)) /*
*/note("Note:95% CI", size(vsmall)) 
gr save margin_distance_robust2, replace
gr export margin_distance_robust2.png, replace
gr export margin_distance_robust2.eps, replace


margins, at(distance5=(1(1)6) interests=(0 1)) atmeans
marginsplot,title("Marginal Effect of Distance (Distance Recode 2):2014", size(medium)) level(95)/*
*/ ytitle ("Response Level (1-4)", color(black) size(small)) /*
*/xtitle ("Regime Distance", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) /*
*/note("Note:95% CI", size(vsmall)) 
gr save margin_distance_predict_robust2, replace
gr export margin_distance_predict_robust2.png, replace
gr export margin_distance_predict_robust2.eps, replace



***Party affiliation as distance***



regress response c.ccp##c.interests sponsor money male ethnic_m i.agency i.location, cluster(delegate_no)
margins, dydx(ccp) at(interests=(0(1)1))
marginsplot,title("Marginal Effect of CCP Affiliation:2014", size(medium)) level(95)/*
*/ ytitle ("Marginal Effect on Response Level", color(black) size(small)) /*
*/xtitle ("Proposal Type", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/yline(0, lc(black) lp(dash)) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) xscale(range(-0.15 1.15)) /*
*/note("Note:95% CI", size(vsmall)) 
gr save margin_distance_ccp, replace
gr export margin_distance_ccp.png, replace
gr export margin_distance_ccp.eps, replace





**Outside Provincial Jurisdiction**

regress response c.distance##c.interests sponsor money male ethnic_m ccp i.agency i.location if authority!=1, cluster(delegate_no)
margins, dydx(distance) at(interests=(0(1)1))
marginsplot,title("Marginal Effect of Distance to the Regime on Response Level: 2014" "(exclude outside jurisdiction proposal)", size(medium)) level(95)/*
*/ ytitle ("Marginal Effect on Response Level", color(black) size(small)) /*
*/xtitle ("Proposal Type", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/yline(0, lc(black) lp(dash)) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) xscale(range(-0.15 1.15)) /*
*/note("Note:95% CI", size(vsmall)) 
gr save check_authority, replace
gr export check_authority.png, replace
gr export check_authority.eps, replace

margins, at(distance=(1(1)5) interests=(0 1)) atmeans
marginsplot,title("Predicted Response Level on Regime Distance: 2014" "(exclude outside jurisdiction proposal)", size(medium)) level(95)/*
*/ ytitle ("Response Level (1-4)", color(black) size(small)) /*
*/xtitle ("Regime Distance", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) /*
*/note("Note:95% CI", size(vsmall)) 
gr save check_authority_predict, replace
gr export check_authority_predict.png, replace
gr export check_authority_predict.eps, replace


***Submission in 2014**
use "submission2014.dta",clear

heckman uni_percent distance male ethnic_m ccp, select(distance male ethnic_m ccp) vce(robust)
outreg2 using "heckman_2014.xls", word label replace
heckman uni_percent distance male ethnic_m ccp age edu, select(distance male ethnic_m ccp age edu) vce(robust)
outreg2 using "heckman_2014.xls", word label append









*************************************************************************************
*************************************************************************************
*************************************************************************************
**# 2016 Analysis      **************************************************************
*************************************************************************************
*************************************************************************************
*************************************************************************************
clear
use "anhui_data_replicate.dta", replace

drop if year==2014


****ANALYSIS****
*****************
regress response c.distance##c.interests sponsor money male ethnic_m ccp i.agency i.location, cluster(delegate_no)
margins, dydx(distance) at(interests=(0(1)1))
marginsplot,title("Marginal Effect of Distance to the Regime on Response Level:2016", size(medium)) level(95)/*
*/ ytitle ("Marginal Effect on Response Level", color(black) size(small)) /*
*/xtitle ("Proposal Type", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/yline(0, lc(black) lp(dash)) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) xscale(range(-0.15 1.15)) /*
*/note("Note:95% CI", size(vsmall)) 
gr save 126_margin_distance, replace
gr export 126_margin_distance.png, replace
gr export 126_margin_distance.eps, replace

margins, at(distance=(1(1)5) interests=(0 1)) atmeans
marginsplot,title("Predicted Response Level on Regime Distance:2016", size(medium)) level(95)/*
*/ ytitle ("Response Level (1-4)", color(black) size(small)) /*
*/xtitle ("Regime Distance", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) /*
*/note("Note:95% CI", size(vsmall)) 
gr save 126_margin_distance_predict, replace
gr export 126_margin_distance_predict.png, replace
gr export 126_margin_distance_predict.eps, replace




eststo clear
eststo: quietly regress response c.distance##c.interests
eststo: quietly regress response c.distance##c.interests sponsor money male ethnic_m ccp i.agency i.location, cluster(delegate_no)
eststo: quietly regress response c.distance##c.interests money sponsor male ccp ethnic_m edu age i.agency i.location, cluster(delegate_no)





esttab using main_reg_2016.rtf, keep(distance interests c.distance#c.interests money sponsor male ccp ethnic_m edu age _cons) b(%9.3fc) label replace se ///
stats(N r2, fmt(%9.3fc) labels("Observations" "R2")) ///
star(* 0.05 ** 0.01 *** 0.001) eqlabels("") title(Regression Results )

eststo clear


****Ordinal Logit

eststo clear
eststo: quietly olog response c.distance##c.interests
eststo: quietly olog response c.distance##c.interests money sponsor male ethnic_m ccp i.agency i.location, cluster(delegate_no)
eststo: quietly olog response c.distance##c.interests money sponsor male ethnic_m ccp edu age i.agency i.location, cluster(delegate_no)


esttab using main_olog_2016.rtf, keep(distance interests c.distance#c.interests money sponsor male ccp ethnic_m edu age) b(%9.3fc) label replace se ///
stats(N r2_p chi2, fmt(%9.3fc) labels("Observations" "pseudo-R2" "Chi-Squared")) ///
star(* 0.05 ** 0.01 *** 0.001) eqlabels("") title(Regression Results )

eststo clear


*** Distance as Dummy****
regress response i.distance##c.interests sponsor money male ethnic_m ccp i.agency i.location, cluster(delegate_no)


margins, dydx(interests) at(distance=(1(1)5))
marginsplot,title("Marginal Effect of Proposal Interests on Response Level:2016", size(medium)) level(95)/*
*/ ytitle ("Response Level (1-4)", color(black) size(small)) /*
*/xtitle ("Regime Distance (Categorical)", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/yline(0, lc(black) lp(dash)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) /*
*/note("Note:95% CI; For Interests: 0 (Particularistic) 1 (Universalistic)", size(vsmall)) 
gr save margin_distance_predict_2016, replace
gr export margin_distance_predict_dummy_2016.png, replace
gr export margin_distance_predict_dummy_2016.eps, replace


***Response as Binary***
preserve 
recode response 1=0 2=0 3=1 4=1

logit response c.distance##c.interests sponsor money male ethnic_m ccp i.agency i.location, cluster(delegate_no)
margins, dydx(distance) at(interests=(0(1)1))
marginsplot,title("Marginal Effect of Distance to the Regime on Response (Binary): 2016", size(small)) level(95)/*
*/ ytitle ("Marginal Effect on Response Level", color(black) size(small)) /*
*/xtitle ("Proposal Type", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/yline(0, lc(black) lp(dash)) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) xscale(range(-0.15 1.15)) /*
*/note("Note:95% CI; Response is Binary", size(vsmall)) 
gr save margin_distance_2016, replace
gr export margin_distance_logit_2016.png, replace
gr export margin_distance_logit_2016.eps, replace


restore


***Recode Response level***
gen res=response
recode res 4=3

gen res2=response
recode res2 3=2 4=3

gen res3=response
recode res3 2=1 4=3 3=2


eststo clear
eststo: quietly regress res c.distance##c.interests money sponsor male ccp ethnic_m i.agency i.location, cluster(delegate_no)
eststo: quietly regress res2 c.distance##c.interests money sponsor male ccp ethnic_m i.agency i.location, cluster(delegate_no)
eststo: quietly regress res3 c.distance##c.interests money sponsor male ccp ethnic_m i.agency i.location, cluster(delegate_no)






esttab using main_reg_check_2016.rtf, keep(distance interests c.distance#c.interests money sponsor male ccp ethnic_m _cons) b(%9.3fc) label replace se ///
stats(N r2, fmt(%9.3fc) labels("Observations" "R2")) ///
star(* 0.05 ** 0.01 *** 0.001) eqlabels("") title(Regression Results )

eststo clear




**Matching**

gen outsider=1 if distance>3
replace outsider=0 if distance<=3
gen int_bi=1 if interests==0 
replace int_bi=0 if interests==1
tab int_bi



eststo clear
eststo: teffects nnmatch (response money sponsor male ccp ethnic_m location) (outsider) if int_bi==1, nneighbor(1)
eststo: teffects nnmatch (response money sponsor male ccp ethnic_m location ) (outsider) if int_bi==1, nneighbor(2)
eststo: teffects nnmatch (response money sponsor male ccp ethnic_m location ) (outsider) if int_bi==1, nneighbor(4)
eststo: teffects nnmatch (response money sponsor male ccp ethnic_m location ) (outsider) if int_bi==1, nneighbor(8)
esttab using outsider_matching_2016_par.rtf, pr2(2) b(2) se(2) starlevels(* 0.1 ** .05 *** .01) label replace
eststo clear


eststo clear
eststo: teffects nnmatch (response money sponsor male ccp ethnic_m location ) (outsider) if int_bi==0, nneighbor(1)
eststo: teffects nnmatch (response money sponsor male ccp ethnic_m location ) (outsider) if int_bi==0, nneighbor(2)
eststo: teffects nnmatch (response money sponsor male ccp ethnic_m location ) (outsider) if int_bi==0, nneighbor(4)
eststo: teffects nnmatch (response money sponsor male ccp ethnic_m location ) (outsider) if int_bi==0, nneighbor(8)
esttab using outsider_matching_2016_uni.rtf, pr2(2) b(2) se(2) starlevels(* 0.1 ** .05 *** .01) label replace
eststo clear







******NO Difference in asking universal request
gen int3=1 if interests==1
replace int3=0 if interests==0
eststo:logit int3 distance i.location i.agency, robust cluster(delegate_no)

eststo:logit int3 distance sponsor money male ethnic_m ccp i.location i.agency, robust cluster(delegate_no)
eststo:logit int3 distance sponsor money male ethnic_m ccp edu age i.location i.agency, robust cluster(delegate_no)



esttab using request_log_2016.rtf, keep(distance money sponsor male ccp ethnic_m edu age _cons) b(%9.3fc) label replace se ///
stats(N r2_p chi2, fmt(%9.3fc) labels("Observations" "pseudo-R2" "Chi-Squared")) ///
star(* 0.05 ** 0.01 *** 0.001) eqlabels("") title(Regression Results )


eststo clear


*************Interaction Effect Test (Xu)
twoway (sc response distance) (lowess response distance),by(, title("Scatter Plot: 2016")) by(interests)  ytitle(Response) xtitle(Distance) saving(scatter,replace)
gr export plot126.png,replace



interflex response distance interests money sponsor male ccp ethnic_m, fe(agency location) type(linear) vce(cluster) xd(density) xlab("Request of Interests") /*
*/ylab("Level of Responses") dlab("Regime Distance") cluster(delegate_no) title("Linear Estimation of Interaction Effect (2016)") sav(123_interaction_test_density.eps)

interflex response distance interests money sponsor male ccp ethnic_m, fe(agency location) type(kernel) vce(cluster) xd(density) xlab("Request of Interests") /*
*/ylab("Level of Responses") dlab("Regime Distance") cluster(delegate_no) bw(0.2244) title("Kernel Estimation of Interaction Effect (2016)") sav(126_interaction_test_kernel.eps)


interflex response interests distance money sponsor male ccp ethnic_m, fe(agency location) type(linear) vce(cluster) xd(density) xlab("Regime Distance") /*
*/ylab("Level of Responses") dlab("Proposal Interests") cluster(delegate_no) title("Linear Estimation of Interaction Effect (2016)") sav(126_interaction_test_density2.eps)

interflex response interests distance money sponsor male ccp ethnic_m, fe(agency location) type(kernel) vce(cluster) xd(density) xlab("Regime Distance") /*
*/ylab("Level of Responses") dlab("Proposal Interests") cluster(delegate_no) bw(0.2244) title("Kernel Estimation of Interaction Effect (2016)") sav(126_interaction_test_kernel2.eps)





*****Different Coding of Distance***



regress response c.distance2##c.interests sponsor money male ethnic_m ccp i.agency i.location, cluster(delegate_no)
margins, dydx(distance2) at(interests=(0(1)1))
marginsplot,title("Marginal Effect of Distance (Distance Recode 4):2016", size(medium)) level(95)/*
*/ ytitle ("Marginal Effect on Response Level", color(black) size(small)) /*
*/xtitle ("Proposal Type", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/yline(0, lc(black) lp(dash)) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) xscale(range(-0.15 1.15)) /*
*/note("Note:95% CI", size(vsmall)) 
gr save margin_distance_robust4, replace
gr export margin_distance_robust4.png, replace
gr export margin_distance_robust4.eps, replace


margins, at(distance2=(1(1)6) interests=(0 1)) atmeans
marginsplot,title("Marginal Effect of Distance (Distance Recode 4):2016", size(medium)) level(95)/*
*/ ytitle ("Response Level (1-4)", color(black) size(small)) /*
*/xtitle ("Regime Distance", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) /*
*/note("Note:95% CI", size(vsmall)) 
gr save 126_margin_distance_predict_robust4, replace
gr export 126_margin_distance_predict_robust4.png, replace
gr export 126_margin_distance_predict_robust4.eps, replace




regress response c.distance3##c.interests sponsor money male ethnic_m ccp i.agency i.location, cluster(delegate_no)
margins, dydx(distance3) at(interests=(0(1)1))
marginsplot,title("Marginal Effect of Distance (Distance Recode 1):2016", size(medium)) level(95)/*
*/ ytitle ("Marginal Effect on Response Level", color(black) size(small)) /*
*/xtitle ("Proposal Type", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/yline(0, lc(black) lp(dash)) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) xscale(range(-0.15 1.15)) /*
*/note("Note:95% CI", size(vsmall)) 
gr save 126_margin_distance_robust1, replace
gr export 126_margin_distance_robust1.png, replace
gr export 126_margin_distance_robust1.eps, replace


margins, at(distance3=(1(1)5) interests=(0 1)) atmeans
marginsplot,title("Marginal Effect of Distance Response Level (Distance Recode 1):2016", size(medium)) level(95)/*
*/ ytitle ("Response Level (1-4)", color(black) size(small)) /*
*/xtitle ("Regime Distance", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) /*
*/note("Note:95% CI", size(vsmall)) 
gr save 126_margin_distance_predict_robust1, replace
gr export 126_margin_distance_predict_robust1.png, replace
gr export 126_margin_distance_predict_robust1.eps, replace




regress response c.distance4##c.interests sponsor money male ethnic_m ccp i.agency i.location, cluster(delegate_no)
margins, dydx(distance4) at(interests=(0(1)1))
marginsplot,title("Marginal Effect of Distance (Distance Recode 3):2016", size(medium)) level(95)/*
*/ ytitle ("Marginal Effect on Response Level", color(black) size(small)) /*
*/xtitle ("Proposal Type", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/yline(0, lc(black) lp(dash)) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) xscale(range(-0.15 1.15)) /*
*/note("Note:95% CI", size(vsmall)) 
gr save 126_margin_distance_robust3, replace
gr export 126_margin_distance_robust3.png, replace
gr export 126_margin_distance_robust3.eps, replace


margins, at(distance4=(1(1)6) interests=(0 1)) atmeans
marginsplot,title("Marginal Effect of Distance (Distance Recode 3):2016", size(medium)) level(95)/*
*/ ytitle ("Response Level (1-4)", color(black) size(small)) /*
*/xtitle ("Regime Distance", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) /*
*/note("Note:95% CI", size(vsmall)) 
gr save 126_margin_distance_predict_robust3, replace
gr export 126_margin_distance_predict_robust3.png, replace
gr export 126_margin_distance_predict_robust3.eps, replace


regress response c.distance5##c.interests sponsor money male ethnic_m ccp i.agency i.location, cluster(delegate_no)
margins, dydx(distance5) at(interests=(0(1)1))
marginsplot,title("Marginal Effect of Distance (Distance Recode 2):2016", size(medium)) level(95)/*
*/ ytitle ("Marginal Effect on Response Level", color(black) size(small)) /*
*/xtitle ("Proposal Type", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/yline(0, lc(black) lp(dash)) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) xscale(range(-0.15 1.15)) /*
*/note("Note:95% CI", size(vsmall)) 
gr save 126_margin_distance_robust2, replace
gr export 126_margin_distance_robust2.png, replace
gr export 126_margin_distance_robust2.eps, replace


margins, at(distance5=(1(1)6) interests=(0 1)) atmeans
marginsplot,title("Marginal Effect of Distance (Distance Recode 2):2016", size(medium)) level(95)/*
*/ ytitle ("Response Level (1-4)", color(black) size(small)) /*
*/xtitle ("Regime Distance", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) /*
*/note("Note:95% CI", size(vsmall)) 
gr save 126_margin_distance_predict_robust2, replace
gr export 126_margin_distance_predict_robust2.png, replace
gr export 126_margin_distance_predict_robust2.eps, replace




***Party Affiliation as distance***

regress response c.ccp##c.interests sponsor money male ethnic_m i.agency i.location, cluster(delegate_no)
margins, dydx(ccp) at(interests=(0(1)1))
marginsplot,title("Marginal Effect of CCP Affiliation:2016", size(medium)) level(95)/*
*/ ytitle ("Marginal Effect on Response Level", color(black) size(small)) /*
*/xtitle ("Proposal Type", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/yline(0, lc(black) lp(dash)) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) xscale(range(-0.15 1.15)) /*
*/note("Note:95% CI", size(vsmall)) 
gr save 126_margin_distance_ccp, replace
gr export 126_margin_distance_ccp.png, replace
gr export 126_margin_distance_ccp.eps, replace




**Outside Provincial Jurisdiction

regress response c.distance##c.interests sponsor money male ethnic_m ccp i.agency i.location if authority!=1, cluster(delegate_no)
margins, dydx(distance) at(interests=(0(1)1))
marginsplot,title("Marginal Effect of Distance to the Regime on Response Level: 2016" "(exclude outside jurisdiction proposal)", size(medium)) level(95)/*
*/ ytitle ("Marginal Effect on Response Level", color(black) size(small)) /*
*/xtitle ("Proposal Type", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/yline(0, lc(black) lp(dash)) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) xscale(range(-0.15 1.15)) /*
*/note("Note:95% CI", size(vsmall)) 
gr save 126_check_authority, replace
gr export 126_check_authority.png, replace
gr export 126_check_authority.eps, replace

margins, at(distance=(1(1)5) interests=(0 1)) atmeans
marginsplot,title("Predicted Response Level on Regime Distance: 2016" "(exclude outside jurisdiction proposal)", size(medium)) level(95)/*
*/ ytitle ("Response Level (1-4 )", color(black) size(small)) /*
*/xtitle ("Regime Distance", color(black) size(small)) /*
*/xla(,labsize(vsmall)) /*
*/graphregion ( lcolor(black) color(white) ) /*
*/plotregion( fcolor(white)) ylab (, nogrid) plotopts(mc(black) lc(black)) /*
*/note("Note:95% CI", size(vsmall)) 
gr save 126_check_authority_predict, replace
gr export 126_check_authority_predict.png, replace
gr export 126_check_authority_predict.eps, replace


***Submission in 2016**
clear
use "submission2016",clear

heckman uni_percent distance male ethnic_m ccp, select(distance male ethnic_m ccp) vce(robust)
outreg2 using "heckman_2016.xls", word label replace
heckman uni_percent distance male ethnic_m ccp age edu, select(distance male ethnic_m ccp age edu) vce(robust)
outreg2 using "heckman_2016.xls", word label append





**# Two Years together as robustness check***
use "anhui_data_replicate.dta", replace

eststo clear
eststo: quietly regress response c.distance##c.interests

eststo: quietly regress response c.distance##c.interests sponsor money male ethnic_m ccp i.agency i.location i.year, cluster(delegate_no)
eststo: quietly regress response c.distance##c.interests money sponsor male ccp ethnic_m edu age i.agency i.location i.year, cluster(delegate_no)



esttab using main_reg_combined.rtf, keep(distance interests c.distance#c.interests money sponsor male ccp ethnic_m edu age _cons) b(%9.3fc) label replace se ///
stats(N r2, fmt(%9.3fc) labels("Observations" "R2")) ///
star(* 0.05 ** 0.01 *** 0.001) eqlabels("") title(Regression Results )

eststo clear
